<?php
if (!defined("BASEPATH")) exit("No direct script access allowed");

class Szotar extends MY_Model {

	function __construct() {
		parent::__construct();
		$this->tableName = "szotar";
		$this->prefix = "szo";
	}

	function getSzotar($szoTipus, $urlName = FALSE) {
		if(!is_array($szoTipus)) {
			$szoTipus = array("'".$szoTipus."'");
		} else {
			foreach($szoTipus as $key => $val) {
				$szoTipus[$key] = "'".$val."'";
			}
		}
		$qs =	"
					select
						szo_type, szo_sname, szo_lname, szo_url_name
					from
						".$this->db->dbprefix.$this->tableName."
					where
						szo_del = 0 and szo_type in (".implode(",", $szoTipus).")
					order by
						szo_type, szo_lname
					";
		$result = $this->db->query($qs);
		$arrSzotar = array();
			foreach ($result->result() as $row) {
				if($urlName) {
					$arrSzotar[$row->szo_type][$row->szo_sname]["szoLname"] = $row->szo_lname;
					$arrSzotar[$row->szo_type][$row->szo_sname]["szoUrlName"] = $row->szo_url_name;
				} else {
					$arrSzotar[$row->szo_type][$row->szo_sname] = $row->szo_lname;
				}
			}
		return $arrSzotar;
	}

}

?>